#include <iostream>
using namespace std;
#include <unordered_map>


class Solution {
public:
    int FirstNotRepeatingChar(string str) {
        // write code here
        unordered_map<char, int> hash;
        for (auto s : str)
        {
            hash[s]++;
        }
        int n = str.size();
        for (int i = 0; i < n; i++)
        {
            if (hash[str[i]] == 1)
            {
                return i;
            }
        }
        return -1;
    }
};

bool isUnique(char* astr) {
    int arr[26] = { 0 };
    int n = strlen(astr);
    for (int i = 0; i < n; i++)
    {
        arr[astr[i] - 'a']++;
    }
    for (int i = 0; i < n; i++)
    {
        if (arr[astr[i] - 'a'] > 1)
        {
            return false;
        }
    }
    return true;
}

class Solution {
public:
    bool isUnique(string astr) {
        unordered_map<char, int> hash;
        for (auto s : astr)
        {
            hash[s]++;
        }
        for (auto s : astr)
        {
            if (hash[s] > 1)
            {
                return false;
            }
        }
        return true;
    }
};

class Solution {
public:
    bool canPermutePalindrome(string s) {
        int ret = 0;
        unordered_map<char, int> hash;
        for (auto ha : s)
        {
            hash[ha]++;
            if (hash[ha] % 2 == 1)
            {
                ret++;
            }
            else
            {
                ret--;
            }
        }
        if (ret > 1)
        {
            return false;
        }
        return true;
    }
};